class Shader
{
	char* vs_src;
	char* ps_src;
	char* gs_src;

	GLhandleARB program;
	GLhandleARB vsh;
	GLhandleARB psh;
	GLhandleARB gsh;

	bool compiled;
	bool vs_exists,ps_exists,gs_exists;
	int init();
	char *name;

	int validated;
	int binded;
public:
	Shader();
	Shader(const char* file);	
	Shader(const char* vertex,const char* pixel);

	Shader(unsigned int type, const char *pixshader);
	~Shader();
	int Compile();
	void Bind();
	void UnBind();
	bool LoadVertexShader(const char* file);
	bool LoadPixelShader(const char* file);
	bool LoadGeometryShader(const char* file);

	bool isCompiled();
	bool WriteInt(const char* vname,const int value);
	bool WriteFloat(const char* vname,const float value);
	bool Write4fv(const char* vname,const float *value);
	bool WriteEyeSpaceVector(const char* vname,const float *fvec);
	bool WriteEyeSpaceVector(const char* vname,float x,float y,float z);
	bool WriteEyeSpaceEntity(const char* vname,Entity *ent);

	bool WriteInt(int location,const int value);
	bool WriteFloat(int location,const float value);
	bool Write4fv(int location,const float *value);
	bool WriteEyeSpaceVector(int location,const float *fvec);
	bool WriteEyeSpaceVector(int location,float x,float y,float z);
	bool WriteEyeSpaceEntity(int location,Entity *ent);

	bool WriteAttribLocation(const char* attname,int location);
	int GetAttribLocation(const char* attname);
	int GetUniformLocation(const char* vname);

	bool ProgramParameter(int pname,int value);
};

namespace sgl_shaders
{
	int version;
	int gs_support;

	void init();
	Shader *current;
	std::vector<std::string> predefinations;

	void AddPredefination(const char *str);
	std::string GetPredefinationString();
}

